/*
 * 
 * liuhongjun
 * 修改成功提示框
 * 引用modityTip.css
 * 
 */
function CheckUpdateFalied(){
	var tipHtml = '';
	tipHtml = '<span class="gtl_ico_fail"></span>'+ErrorMsgConstants.ERR_TIP_MODIFY;
	$("#tip").html(tipHtml);
$(".msgbox_layer_wrap").css("display","block");
	$(".msgbox_layer_wrap").show();
	var st = setTimeout(function (){
		$(".msgbox_layer_wrap").hide();
		$(".msgbox_layer_wrap").css("display","none");

		clearTimeout(st);
	},1000);
}
function CheckUpdateSuccess(){
	var tipHtml = '';
	tipHtml = '<span class="gtl_ico_succ"></span>'+ValidMsgConstants.MODIFY_TIP;
	
	$("#tip").html(tipHtml);
	$(".msgbox_layer_wrap").css("display","block");
	$(".msgbox_layer_wrap").show();
	var st = setTimeout(function (){
		$(".msgbox_layer_wrap").hide();
		$(".msgbox_layer_wrap").css("display","none");
		
		clearTimeout(st);
	},1000);
}

/**
 * 
 * 正在加载图片显示
 * liuhongjun
 * divId:加载部分的外部DIV
 * megId:要加载的部分
 * 0:加载图显示
 * 1:图片加载
 * 2:非加载形式
 * */
function loading(divId){
	var divWidth = ($("#"+divId).position().left + $("#"+divId).width()/2)+"px";
	var divTop = ($("#"+divId).position().top + $("#"+divId).height()/2)+"px";
	var loadingImg = "<div id='loading' class='loading'><div class='loading_img'></div><div class='loading_text'>正在加载...</div></div>";
	$("#loading").css("left",divWidth);
	$("#loading").css("top",divTop);
	$("#"+divId).prepend(loadingImg);
}
function loadingWaiting(divId , megId, type){
	if(type.indexOf("0") != -1){
		loading(divId);
		}
	if(type.indexOf("1") != -1){
		document.getElementById(megId).onload = function(){
			$("#loading").css("display","none");
		};
	}
	if(type.indexOf("2") != -1){
		$("#loading").css("display","none");
	}
}
function colorToRGB(color) {

	var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/g;

	var sColor = color.toLowerCase();

	if(sColor && reg.test(sColor)){

		if(sColor.length === 4){

			var sColorNew = "#";

			for(var i=1; i<4; i+=1){

				sColorNew += sColor.slice(i,i+1).concat(sColor.slice(i,i+1));

			}

			sColor = sColorNew;

		}

		//处理六位的颜色值

		var sColorChange = [];

		for(var i=1; i<7; i+=2){

			sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)));

		}

		return sColorChange.join(",");

	}else{

		return color;

	}

}
function setBakckgoundAndOpacity(obj, color, opacity) {

	var rgbaObj = colorToRGB(color);

	if(jQuery.browser.msie && parseInt(jQuery.browser.version) < 9) {

		// 针对ie 6，7，8 通过设置内部元素position:relative；可以避免被父节点的opacity影响

		jQuery(obj).children().each(function(){

			if(jQuery(this).css('position') == 'static'){

				jQuery(this).css('position','relative');

			}

		});

		jQuery(obj).css({
	
			'background':color,
	
			'opacity':opacity
	
		});

	}else{

		// 支持rgba颜色格式的浏览器用rgba设置透明背景色

		jQuery(obj).css({

			'background':'rgba('+rgbaObj+','+opacity+')'

		});

	}
}

/**************************背景半透明处理***************************/

$(function() {
	setBakckgoundAndOpacity($('#isLogin'),'#000000','0.3');
});


